package com.haois.mp.database.module.sdk.api;

import com.haois.mp.database.commom.constant.ApiAppKey;
import com.haois.mp.database.util.HttpClientUtil;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Value;


/**
 * Created by RuiHaoZ on 2018/4/4 23:54
 * http://www.tuling123.com/
 * https://www.kancloud.cn/turing/web_api/522992
 */
public class TuLingService {
    private String serverUrl;

    private String apiKey;

    private String apiSecret;


    public static String question(String question) {
        String serverUrl = ApiAppKey.TuLing_ServerUrl;
        String apiKey = ApiAppKey.TuLing_ApiKey;
        String apiSecret = ApiAppKey.TuLing_ApiSecret;
        JSONObject u = new JSONObject();
        u.put("apiKey", apiKey);
        u.put("apiSecret", apiSecret);
        JSONObject p = new JSONObject();
        p.put("inputText", question);
        JSONObject z = new JSONObject();
        z.put("reqType", "0");
        z.put("perception", p.toString());
        z.put("userInfo", u.toString());

        System.out.println(z);
        String response = HttpClientUtil.sendPost(serverUrl, z, null);
        return response;
    }
}
